<!-- Headers -->
<div class="container-fluid" style="padding:0;">
  <!-- Header -->
  <header class="header">
    <div class="page-header">
      <span class="logo glyphicon glyphicon-info-sign"></span>
      <span class="title">系统信息</span>
    </div>
  </header>
</div>

<!-- Main component for a primary marketing message or call to action -->
<div class="container-fluid body">
	<!-- Nav tabs -->
	<ul class="nav nav-tabs">
	  <li class="active"><a href="#sys-site-info" data-toggle="tab">系统信息</a></li>
	  <li><a href="#php-settings" data-toggle="tab">PHP 设置</a></li>
	</ul>

	<!-- Tab panes -->
	<div class="tab-content">
	  <div class="tab-pane active" id="sys-site-info">
	  	<table class="table table-striped">
	      <thead>
	        <tr>
	          <th width="25%">Setting</th>
	          <th>Value</th>
	        </tr>
	      </thead>
	      <tbody>
	        <tr>
	          <td>Web Server</td>
	          <td name="server"></td>
	        </tr>
	        <tr>
	          <td>PHP Built On</td>
	          <td name="build"></td>
	        </tr>
	        <tr>
	          <td>PHP Version</td>
	          <td name="php"></td>
	        </tr>
	        <tr>
	          <td>MySQL Version</td>
	          <td name="mysql"></td>
	        </tr>
	        <tr>
	          <td>System Time</td>
	          <td name="time"></td>
	        </tr>
	        <tr>
	          <td>User Agent</td>
	          <td name="agent"></td>
	        </tr>
	        <tr>
	          <td>System Version</td>
	          <td name="version"></td>
	        </tr>
	      </tbody>
	    </table>
	  </div>
	  <div class="tab-pane" id="php-settings">
	  	<table class="table table-striped">
	      <thead>
	        <tr>
	          <th width="25%">Setting</th>
	          <th>Value</th>
	        </tr>
	      </thead>
	      <tbody>
	        <tr>
	          <td>Safe Mode</td>
	          <td name="safe_mode"></td>
	        </tr>
	        <tr>
	          <td>Html Errors</td>
	          <td name="html_errors"></td>
	        </tr>
	        <tr>
	          <td>Display Errors</td>
	          <td name="display_errors"></td>
	        </tr>
	        <tr>
	          <td>File Uploads</td>
	          <td name="file_uploads"></td>
	        </tr>
	        <tr>
	          <td>Output Buffering</td>
	          <td name="output_buffering"></td>
	        </tr>
	        <tr>
	          <td>Max File Uploads</td>
	          <td name="max_file_uploads"></td>
	        </tr>
	        <tr>
	          <td>Memory Limit</td>
	          <td name="memory_limit"></td>
	        </tr>
	        <tr>
	          <td>Max Execution Time</td>
	          <td name="max_execution_time"></td>
	        </tr>
	      </tbody>
	    </table>
	  </div>
	</div>
</div>

<script type="text/javascript">

  function load() {
  	load_sys_info();
  	load_php_settings();
  }

  function load_sys_info() {
    $.ajax({
      url: 'system/info',
      success: function(data, status) {
        if (data == undefined) return;
        if (data.build != undefined) $("#sys-site-info").find("td[name='build']").append(data.build);
		if (data.server != undefined) $("#sys-site-info").find("td[name='server']").append(data.server);
        if (data.sys != undefined) $("#sys-site-info").find("td[name='sys']").append(data.sys);
        if (data.php != undefined) $("#sys-site-info").find("td[name='php']").append(data.php);
        if (data.time != undefined) $("#sys-site-info").find("td[name='time']").append(data.time);
        if (data.mysql != undefined) $("#sys-site-info").find("td[name='mysql']").append(data.mysql);
        if (data.agent != undefined) $("#sys-site-info").find("td[name='agent']").append(data.agent);
        if (data.ver != undefined) $("#sys-site-info").find("td[name='version']").append(data.ver);
      },
      error: function(hxr, status, error) {
        // $("#sys-site-info").attr('class', 'panel panel-danger');
      }
   });
  }
  function load_php_settings() {
    $.ajax({
      url: 'system/php/settings',
      success: function(data, status) {
        if (data == undefined) return;
        if (data.safe_mode != undefined) $("#php-settings").find("td[name='safe_mode']").append(data.safe_mode == '' ? 'No' : 'Yes');
        if (data.html_errors != undefined) $("#php-settings").find("td[name='html_errors']").append(data.html_errors == 1 ? 'Yes' : 'No');        
		if (data.display_errors != undefined) $("#php-settings").find("td[name='display_errors']").append(data.display_errors == 1 ? 'Yes' : 'No');
        if (data.file_uploads != undefined) $("#php-settings").find("td[name='file_uploads']").append(data.file_uploads == 1 ? 'Yes' : 'No');
        if (data.output_buffering != undefined) $("#php-settings").find("td[name='output_buffering']").append(data.output_buffering == 1 ? 'Yes' : 'No');
        if (data.max_file_uploads != undefined) $("#php-settings").find("td[name='max_file_uploads']").append(data.max_file_uploads);
        if (data.memory_limit != undefined) $("#php-settings").find("td[name='memory_limit']").append(data.memory_limit);
        if (data.max_execution_time != undefined) $("#php-settings").find("td[name='max_execution_time']").append(data.max_execution_time + 's');
      },
      error: function(hxr, status, error) {
        // $("#php-settings").attr('class', 'panel panel-danger');
      }
   });
  }
</script>